using System;
using System.IO;
using System.Text;

namespace ELS.User
{
	//<Summary>
	// This class used to created log files
	// Created by ali mohamed  - 2012
	//</Summary>

    /// <summary>
    /// Class LogFile
    /// </summary>
	public class LogFile
	{
        /// <summary>
        /// The s log format
        /// </summary>
		private static string sLogFormat;
        /// <summary>
        /// The s error time
        /// </summary>
		private static string sErrorTime;

        /// <summary>
        /// Creates the log files.
        /// </summary>
		public static void CreateLogFiles()
		{
			//sLogFormat used to create log files format :
			// dd/mm/yyyy hh:mm:ss AM/PM ==> Log Message
			sLogFormat = DateTime.Now.ToShortDateString().ToString()+" " + DateTime.Now.ToLongTimeString().ToString()+" ==> ";
			
			//this variable used to create log filename format "
			//for example filename : ErrorLogYYYYMMDD
			string sYear	= DateTime.Now.Year.ToString();
			string sMonth	= DateTime.Now.Month.ToString();
			string sDay	= DateTime.Now.Day.ToString();
			sErrorTime = sYear+sMonth+sDay;
		}

        /// <summary>
        /// Errors the log.
        /// </summary>
        /// <param name="sPathName">Name of the s path.</param>
        /// <param name="sErrMsg">The s err MSG.</param>
		public static void ErrorLog(string sPathName, string sErrMsg)
		{
			StreamWriter sw = new StreamWriter(sPathName+sErrorTime,true);
			sw.WriteLine(sLogFormat + sErrMsg);
			sw.Flush();
			sw.Close();
		}
	}
}
